<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>lpshold</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="lpreson.html" title="lpreson" />
    <link rel="next" href="lpsholdp.html" title="lpsholdp" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">lpshold</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="lpreson.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="lpsholdp.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="lpshold"></a>
      <div class="titlepage"></div>
      <a id="IndexLpshold" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">lpshold</span>
        </h2>
        <p>lpshold — 
      Generate control signal consisting of held segments.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121900384"></a>
        <h2>Description</h2>
        <p>
      Generate control signal consisting of held segments delimited by two or more specified points. The entire envelope is looped at <span class="emphasis"><em>kfreq</em></span> rate. Each parameter can be varied at k-rate.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121902208"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ksig <span class="command"><strong>lpshold</strong></span> kfreq, ktrig, iphase, ktime0, kvalue0  [, kvalue1] [, ktime1] [, kvalue2] [, ktime2] [...]</pre>
      </div>
      <div class="refsect1">
        <a id="idp121904528"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ksig</em></span> -- Output signal
    </p>
        <p>
      <span class="emphasis"><em>kfreq</em></span> -- Repeat rate in Hz or fraction of Hz
    </p>
        <p>
      <span class="emphasis"><em>ktrig</em></span> -- If non-zero, retriggers the envelope from start (see <a class="link" href="trigger.html" title="trigger"><em class="citetitle">trigger opcode</em></a>), before the envelope cycle is completed.
    </p>
        <p>
      <span class="emphasis"><em>iphase</em></span> -- A vaue between 0 and 1 to say
      where to start the loop.  Zero, the commonest value, indicates
      the beginning.
    </p>
        <p>
      <span class="emphasis"><em>kvalue0...kvalueN</em></span> -- Values of points
    </p>
        <p>
      <span class="emphasis"><em>ktime0...ktimeN</em></span> -- Times between points; expressed in fractions of a cycle (see below). The final time designates a ramp between the final value and the first value. 
    </p>
        <p>
      <span class="emphasis"><em>lpshold</em></span> is similar to <a class="link" href="loopseg.html" title="loopseg"><em class="citetitle">loopseg</em></a>, but can generate only horizontal segments, i.e. holds values for each time interval placed between <span class="emphasis"><em>ktimeN</em></span> and <span class="emphasis"><em>ktimeN+1</em></span>. It can be useful, among other things, for melodic control, like old analog sequencers.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121915136"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the lpshold opcode. It uses the file <a class="ulink" href="examples/lpshold.csd" target="_top"><em class="citetitle">lpshold.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp121916992"></a>
          <p class="title">
            <strong>Example 461. Example of the lpshold opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac      <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o lpshold.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1
kfrq  <span class="opc">init</span>    p4  <span class="comment">; frequency of the loop </span>
ifrac <span class="op">=</span>       p5  <span class="comment">; fraction of frequency at which to force retrigger</span>
ipan  <span class="op">=</span>       p6  <span class="comment">; pan position</span>
ktrig <span class="opc">metro</span>   kfrq <span class="op">*</span> ifrac  <span class="comment">; trigger to force restart the loop</span>
iphs  <span class="op">=</span>       0   <span class="comment">; initial phase of the loop</span>
<span class="comment">; a loop of midi note numbers:   note duration etc...</span>
knote <span class="opc">lpshold</span> kfrq, ktrig, iphs, 61,  0.0625,  60, 0.9375,   61, 1, 58, 1, \
63, 2, 65, 3
aenv  <span class="opc">linseg</span> 0,0.01,1,p3<span class="op">-</span>0.11,1,0.1,0   <span class="comment">; amplitude envelope</span>
krnd  <span class="opc">rspline</span> <span class="op">-</span>0.05,0.05,0.5,1 <span class="comment">; random detune</span>
asig  <span class="opc">gbuzz</span>   0.2<span class="op">*</span>aenv, <span class="opc">cpsmidinn</span>(knote<span class="op">+</span>krnd), 30, 1, 0.5, 1 
      <span class="opc">outs</span>    asig<span class="op">*</span>ipan, asig<span class="op">*</span>(1<span class="op">-</span>ipan)
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; cosine wave.</span>
<span class="stamnt">f</span> 1 0 16384 11 1

<span class="comment">; 3 layers of the loop are played, each at a different speed, </span>
<span class="comment">; - with different retriggering rate, and pan location.</span>
<span class="stamnt">i</span> 1 0 60 0.5   [8/10] 0.5
<span class="stamnt">i</span> 1 0 60 0.375 [8/11] 0.1
<span class="stamnt">i</span> 1 0 60 0.25  [8/13] 0.9
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121921312"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="loopseg.html" title="loopseg"><em class="citetitle">loopseg</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp121923424"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in Version 4.13</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="lpreson.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="lpsholdp.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">lpreson </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> lpsholdp</td>
        </tr>
      </table>
    </div>
  </body>
</html>
